-
Notifications
You must be signed in to change notification settings - Fork 151
bugfix(ocl): Fix uninitialized variable in ObjectCreationList to avoid mismatches #2096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
bugfix(ocl): Fix uninitialized variable in ObjectCreationList to avoid mismatches #2096
Conversation
|
Based on #2095, I tested this on 1800 replays and found no mismatch. |
Thanks, that's good news. |
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/ObjectCreationList.cpp | Fixed critical uninitialized variable bug by checking return value of findPositionAround and falling back to center position when no valid position is found |
Sequence Diagram
sequenceDiagram
participant OCL as ObjectCreationList
participant PM as PartitionManager
participant Obj as Debris Object
OCL->>OCL: Check m_spreadFormation flag
alt m_spreadFormation is true
OCL->>OCL: Initialize resultPos (Coord3D)
OCL->>OCL: Setup FindPositionOptions
OCL->>PM: findPositionAround(pos, fpOptions, &resultPos)
alt Position found
PM-->>OCL: return true (resultPos set)
else Position not found (e.g., large water body)
PM-->>OCL: return false (resultPos uninitialized)
Note over OCL: OLD: Use uninitialized resultPos (MISMATCH!)
Note over OCL: NEW: Set resultPos = *pos (fallback)
OCL->>OCL: DEBUG_CRASH warning (if RETAIL_COMPATIBLE_CRC)
end
OCL->>Obj: doStuffToObj(debris, name, &resultPos, ...)
else m_spreadFormation is false
OCL->>Obj: doStuffToObj(debris, name, pos, ...)
end
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable.
Needs to be replicated in Generals.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/ObjectCreationList.cpp
Show resolved
Hide resolved
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Replicated in Generals. Ready to be merged whenever the other PRs are. |
GeneralsGameCode/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/ObjectCreationList.cpp
Lines 1385 to 1391 in 25e3602
This code is called for the GLA Rebel Ambush special power.
resultPosremains uninitialized iffindPositionAroundfails (returns false), making the behavior undeterministic (i.e. may cause mismatches). This can be tested when calling the special power on a large body of water. Them_maxDistanceFormationis quite large for this special power, so it has to be a large body of water. Mountainous terrain probably also works.For the Contra mod, this is called for the USA Air Force General special power that spawns Comanches, which has a much lower test radius so
findPositionAroundis more likely to fail.TODO: